﻿using System;
using System.Linq;
using LocalOverride.Fiddler.Store;

namespace LocalOverride.Fiddler.UI
{
    internal static class ExtensionMapper
    {
        public static string ToString(FileExtensionList fileExtensions)
        {
            return String.Join(";", fileExtensions.ToArray());
        }

        public static FileExtensionList ToStore(string editExtensions)
        {
            if (String.IsNullOrEmpty(editExtensions))
                return new FileExtensionList();

            var extensions = editExtensions.Split(new[] { ';' });
            var fileExtensionList = new FileExtensionList();
            foreach (var extension in extensions)
            {
                fileExtensionList.Add(extension);
            }

            return fileExtensionList;
        }
    }
}